package health.lm.com.component_base.popup.notice;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.StringUtils;
import com.jakewharton.rxbinding2.view.RxView;
import com.tencent.mm.opensdk.openapi.IWXAPI;

import java.util.concurrent.TimeUnit;

import health.lm.com.component_base.R;
import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.component_base.widget.CustomPopWindow;
import health.lm.com.data.App;

/**
 * 结果提示弹窗
 */

public class NoticePopUtil {
    private static NoticePopUtil sharePopUtil;
    private static Context ctx;
    private CustomPopWindow popWindow;
    private String url;
    private String title;
    private String description;
    private IWXAPI api;

    public static NoticePopUtil getInstance() {
        if (sharePopUtil == null) {
            sharePopUtil = new NoticePopUtil();
        }
        return sharePopUtil;
    }

    /**
     * 显示popwindow  糖果加减
     */
    public void show(Context context, View mLayoutPopup, String content, String content2) {
        ctx = context;
        View contentView = LayoutInflater.from(context).inflate(R.layout.pop_notice, null);
        //图片
        ImageView img = contentView.findViewById(R.id.iv_icon);
        ImageLoaderHelper.getInstance().load(context, App.model.getSugar_url(), img);
        //数量
        TextView tvContent1 = contentView.findViewById(R.id.tv_count);
        tvContent1.setText(content);
        //内容
        TextView tvContent2 = contentView.findViewById(R.id.tv_content);
        if (StringUtils.isEmpty(content2)){
            tvContent2.setVisibility(View.GONE);
        }
        tvContent2.setText(content2);
        //创建并显示popWindow
        //显示大小
        popWindow = new CustomPopWindow.PopupWindowBuilder(context)
                .setView(contentView)
                .enableBackgroundDark(true)
                .setBgDarkAlpha(0.8f)
                .setAnimationStyle(R.style.pop_center_anim)
                .size(500, 500)//显示大小
                .create()
                .showAtLocation(mLayoutPopup, Gravity.CENTER, 0, 0);
    }

}
